package com.io.client;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;

public class TestNIOClient {
    public static void main(String[] args) throws Exception {
        SocketChannel socketChannel  = SocketChannel.open(new InetSocketAddress("127.0.0.1",12345));
//        Thread.sleep(30000);
//        byteBuffer.put(Thread.currentThread().getName().getBytes());
//        byteBuffer.flip();
        while(true) {
            System.out.println("写");
            ByteBuffer byteBuffer = ByteBuffer.allocate(2048);
            byteBuffer.put("3".getBytes());
            byteBuffer.flip();
            socketChannel.write(byteBuffer);
            Thread.sleep(5000);
        }
    }
}
